//
//  SearchBtnView.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/10/23.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "SearchBtnView.h"

@interface SearchBtnView()

@property(nonatomic,strong)UIButton *SearchBtn;

@end

@implementation SearchBtnView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        
        
        self.SearchBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        
        self.SearchBtn.frame=CGRectMake(15, 7, SCREEN_WIDTH-30, 36);
        
        self.backgroundColor=[UIColor whiteColor];
        
        [self.SearchBtn setTitle:@"" forState:UIControlStateNormal];
        
        [self.SearchBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        
        self.SearchBtn.layer.cornerRadius=8.0;
        
        self.SearchBtn.layer.masksToBounds=YES;

        self.SearchBtn.backgroundColor=[UIColor groupTableViewBackgroundColor];

        [self.SearchBtn setImage:[UIImage imageNamed:@"searchImage"] forState:UIControlStateNormal];
        
        self.SearchBtn.titleLabel.font=[UIFont systemFontOfSize:15];
        
        [self.SearchBtn addTarget:self action:@selector(GotoSearch:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:self.SearchBtn];
        
    }
    
    return self;
}


-(void)setPlaceHol:(NSString *)placeHol
{
    _placeHol=placeHol;
    
    [self.SearchBtn setTitle:placeHol forState:UIControlStateNormal];
    
    [self.SearchBtn setImage:[UIImage imageNamed:@"searchImage"] forState:UIControlStateNormal];
}


-(void)GotoSearch:(UIButton*)sender
{
    _block();
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
